<?php

/**
 * Loads model class script (experimental) in a much faster way that require_once
 *        (about 100 times faster).
 * NOTE: be aware that when including the model in the local scope some global
 *          variables from the model script are lost (depending on whether you have
 *          previously defined them or not).
 * @param string $className
 */
function LoadModelClass($className)
{
  if (class_exists($className))
    return;

  // extract variables from the global scope to local scope as references (in
  // case any model uses global variables). This should be save because models
  // should only use existing global variables and not create new ones.
  extract($GLOBALS, EXTR_REFS);
  // include instead of require. Rather than having an error at class declaration
  // we would prefer an error at class instance initialization.
  include_once(Config::get('constants.MODELS_PATH') . '/' . $className  . '.php');
}

?>